package com.nulldev.util.scripting.cup.vee.registers;

import java.util.concurrent.atomic.AtomicReference;

import com.nulldev.util.scripting.cup.vee.CUPRegister;

public class DoubleCUPRegister extends CUPRegister<Double> {

	private final int registerID;

	public DoubleCUPRegister(final int registerID) {
		this.registerID = registerID;
	}

	private final AtomicReference<Double> value = new AtomicReference<Double>(0d);

	@Override
	public CUPRegisterType getRegisterType() {
		return CUPRegisterType.DOUBLE;
	}

	@Override
	public void reset() {
		this.value.set(0d);
	}

	@Override
	public Double get() {
		return this.value.get();
	}

	@Override
	public void set(Double value) {
		this.value.set(value);
	}

	@Override
	public boolean valuePresent() {
		return this.value.get() != null;
	}

	@Override
	public int getRegisterID() {
		return this.registerID;
	}

}
